auto.waitFor();
function 随机数(minNum,maxNum) {
 
  switch(arguments.length){ 
      case 1: 
          return parseInt(Math.random()*minNum+1,10); 
      break; 
      case 2: 
          return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10); 
      break; 
          default: 
              return 0; 
          break; 
  } 

}
启动抖音()
console.log(global.WEB_PARAMS)

搜索数组=global.WEB_PARAMS.keywordsousp.split('\n')


for (var i=0;i<搜索数组.length;i++) {
log(搜索数组[i])
  desc('搜索').findOne()
  sleep(2000)
  
  var a2 = desc('搜索').findOne().bounds().centerX();
  var a3 = desc('搜索').findOne().bounds().centerY();
  press(a2, a3, 1)   //press(x,y,1)
  sleep(1000)
  setText(搜索数组[i])
  sleep(1000)
  var a2 = desc('搜索').findOne().bounds().centerX();
  var a3 = desc('搜索').findOne().bounds().centerY();
  press(a2, a3, 1)   //press(x,y,1)
  sleep(1000)
  text('综合').findOne()
  sleep(1000)
  
  var a2 = text('视频').findOne().bounds().centerX();
  var a3 = text('视频').findOne().bounds().centerY();
  press(a2, a3, 1)   //press(x,y,1)
  sleep(1000)

 u=desc('关注按钮').find()
 if (global.WEB_PARAMS.gznumsousp>u.length){
  global.WEB_PARAMS.gznumsousp=u.length
 }
for (var j=0;j<global.WEB_PARAMS.gznumsousp;j++){
  var a2 = u[j].bounds().centerX();
  var a3 = u[j].bounds().centerY();
  press(a2, a3, 1)   //press(x,y,1)
  sleep(global.WEB_PARAMS.waittimesou*1000)

 sleep(1000)
}
back()
}
toastLog('任务完成')
sleep(3000)
back()

//点赞
function like () {
  var likeBtn = descContains('喜欢').visibleToUser().findOnce()


    likeBtn.click()
    sleep(2000);
    return true

}
//关注

function subscribe(){
  var subscribeBtn=descContains('关注').visibleToUser().findOnce()

    subscribeBtn.click()
    sleep(2000);
    return true

}
function comment(){
  
  var commentBtn=id('user_avatar').visibleToUser().findOnce()

    commentBtn.click()

    sleep(2000);
    desc('私信').findOne().click()
    sleep(2000);
    setText(评论数组[随机数(0,评论数组.length)]  )
    sleep(2000);
    desc('发送').findOne().click()
   back()
   sleep(2000);
   back()
   sleep(2000);
    return true

}